package com.atguigu.tingshu.account;

import com.atguigu.tingshu.account.impl.AccountDegradeFeignClient;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.account.RechargeInfo;
import com.atguigu.tingshu.vo.account.AccountDeductVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * <p>
 * 账号模块远程调用API接口
 * </p>
 *
 * @author atguigu
 */
@FeignClient(value = "service-account", path = "api/account", fallback = AccountDegradeFeignClient.class)
public interface AccountFeignClient {

    /**
     * 用户余额支付订单-验证扣减账户余额
     * TODO:跟虚拟物品发货接口保持一致，用户ID通过入参对象传递。将来采用微信/支付宝支付后，支付宝会有支付成功回调->请求商户系统不会携带Token访问
     *
     * @param accountDeductVo
     * @return 业务调用正常返回业务状态码：200，反之业务失败，触发全局事务回滚
     */
    @PostMapping("/userAccount/checkAndDeduct")
    public Result checkAndDeduct(@RequestBody AccountDeductVo accountDeductVo);


    /**
     * 根据订单编号查询充值记录
     * @param orderNo
     * @return
     */
    @GetMapping("/rechargeInfo/getRechargeInfo/{orderNo}")
    public Result<RechargeInfo> getRechargeInfo(@PathVariable String orderNo);

    /**
     * 在线付款成功后-更新充值状态&账户余额及新增账户变动日志
     *
     * @param orderNo
     * @return
     */
    @GetMapping("/rechargeInfo/rechargePaySuccess/{orderNo}")
    public Result rechargePaySuccess(@PathVariable String orderNo);
}
